package logger;

/**
 * Created by vondoom on 23.10.2014.
 */
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

public class LoggerManager {
    public enum LogLevel {DEBUG, INFO, WARNING, ERROR, FATAL};
    private static LoggerManager obj;
    private Logger oLog;

    private LoggerManager(){
        BasicConfigurator.configure();
    }

    public LoggerManager(Logger logger) {
        this();
        setLogger(logger);
    }

    private void setLogger(Logger _oLog)
    {
        oLog = _oLog;
    }

    public static LoggerManager getLogger(){
        if (obj == null)
            obj = new LoggerManager(Logger.getLogger(LoggerManager.class));

        return obj;
    }

    public void Log(String _sMsg, LoggerManager.LogLevel _eLogLevel){
        switch(_eLogLevel){
            case DEBUG:
                oLog.debug(_sMsg);
                break;
            case INFO:
                oLog.info(_sMsg);
                break;
            case WARNING:
                oLog.warn(_sMsg);
                break;
            case ERROR:
                oLog.error(_sMsg);
                break;
            case FATAL:
                oLog.fatal(_sMsg);
                break;
            default:

        }
    }
}
